package algorithm.lanqiao.t101;
import java.io.*;
import java.util.*;

public class Main {

    static class IOUtil {
        // 读
        static InputStreamReader ins = new InputStreamReader(System.in);
        static StreamTokenizer in = new StreamTokenizer(ins);
        static BufferedReader br = new BufferedReader(ins);

        // 写
        public static PrintWriter out = new PrintWriter(System.out);


        public static int readInt() {
            try {
                in.nextToken();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return (int) in.nval;
        }

        public static String readLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static class Node {
        Node next;
        Character val;

        public Node(Character i) {
            val = i;
        }
    }

    public static void main(String[] args) {
        String strA = IOUtil.readLine();
        String strB = IOUtil.readLine();
        int lenA = strA.length();
        int lenB = strB.length();
        Queue<Character> qa = new LinkedList<>();
        Queue<Character> qb = new LinkedList<>();
        for (int i = 0; i < lenA; i++) {
            qa.add(strA.charAt(i));
        }
        for (int i = 0; i < lenB; i++) {
            qb.add(strB.charAt(i));
        }
        int cnt = 0;
        Map<Character, Node> map = new HashMap<>();
        Node root = new Node('0');
        Node head = root;
        int flag = 1;
        while (!qa.isEmpty() && !qb.isEmpty() && cnt < 1000) {
            Queue<Character> q = flag == 1 ? qa : qb;
            Character character = q.poll();
            Node curNode = new Node(character);
            root.next = curNode;
            root = curNode;
            if (map.containsKey(character)) {
                Node node = map.get(character);
                Node cur = node;
                Stack<Character> stack = new Stack<>();
                while (cur != null) {
                    stack.add(cur.val);
                    map.remove(cur.val);
                    cur = cur.next;
                }
                while (!stack.isEmpty()) {
                    q.add(stack.pop());
                }
                cur = head;
                while (cur != null && cur.next != node) {
                    cur = cur.next;
                }
                map.remove(character);
                if (cur != null) {
                    cur.next = null;
                    root = cur;

                }
            } else {
                flag = 3 - flag;
                map.put(character, curNode);
            }
            cnt++;
        }

        if (!qa.isEmpty() && !qb.isEmpty()) {
            IOUtil.out.println(-1);
        } else if (!qa.isEmpty()) {
            while (!qa.isEmpty()) {
                IOUtil.out.print(qa.poll());
            }
        } else if (!qb.isEmpty()) {
            while (!qb.isEmpty()) {
                IOUtil.out.print(qb.poll());
            }
        }
        IOUtil.out.flush();

    }
}